home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Misc / msql-1.0.6 / doc / scanner.doc < prev    next >
Text File  |  1994-12-12  |  2KB  |  54 lines

  1. mSQL Scanner Notes
  2. ------------------
  3.  
  4. The lexical scanner used by mSQL is hand crafted rather than using a
  5. lex/flex generated scanner.  This has been implemented to firstly avoid
  6. portability problems with various version of lex and flex and secondly
  7. to provide greater flexibility.  It understands C styled escape
  8. conventions within text literals and _should_ handle 8-bit international
  9. character sets.
  10.  
  11. Due to the case-insensitive nature of SQL keywords, lex generated
  12. over 1,500 lines of code including almost 1,600 transition conditions
  13. The hand crafted scanner is only XXXX lines long and uses only 15 states
  14. This is due to a simple, case-insensitive keyword lookup mechanism and
  15. character class matching for state transitions (eg isdigit()).  In
  16. short, it should be quite fast and a lot more readable and portable than
  17. the old scanner.
  18.  
  19. The scanner is a based on a state machine to determine the underlying
  20. tokens.  The states are defined in the transformation digram below.  The
  21. sytax used consists of the {State : LoopChars} where State is the state
  22. number and LoopChars are characters that cause a state loopback.
  23. Characters that force a transition are shown on the edges as a comma
  24. delimited list within <> characters. Terminal states are shown as [State
  25. : Token] indicating the state number and the type of token matched.
  26.  
  27.  
  28. {0} Start State
  29. |__<Alpha>__{1:Alpha}__<Num,'_'>__{3:AlphaNum,'_'}__<other>__[4:IDENT]
  30. |                    |
  31. |                    |__<other>__[2:KEYWORD or IDENT]
  32. |
  33. |
  34. |__<Num>__{5:Num}__<'.'>__{7:Num}__<other>__[8:REAL_NUM]
  35. |        ^       |
  36. |        |       |__<other>__[6:INT_NUM]
  37. |        |
  38. |        |__________________
  39. |                          |
  40. |__<'-','+'>__{9:}__<Num>__|
  41. |                 |
  42. |                 |__<other>__[999:UNMATCHED_CHAR]
  43. |
  44. |
  45. |__<Math>__{10:Math}__<other>__[11:MATH_SYM]
  46. |
  47. |
  48. |__<'"'>__{12:TextString}__<'"'>__[13:TEXT_LITERAL]
  49. |                        |
  50. |                        |__<other>__[999:UNMATCHED_CHAR]
  51. |
  52. |__<NULL>__[1000:END_OF_INPUT]
  53.  
  54.